import {Injectable} from '@angular/core';
import {HttpClient} from '@angular/common/http';
import {NzMessageService} from 'ng-zorro-antd/message';

@Injectable({
  providedIn: 'root'
})
export class PermissionService {
  protected userPermissionUrl = '/sys/role/getUserPermission';
  userPermission = new Set();

  constructor(
    protected httpClient: HttpClient,
    protected msg: NzMessageService,
  ) {
    this.initUserPermission();
  }

  initUserPermission() {
    this.httpClient.get(this.userPermissionUrl).toPromise().then((res: any) => {
      if (res.code !== 0) {
        // this.msg.error(res.message);
      } else {
        this.userPermission = new Set(res.data);
      }
    });
  }
}
